package com.me.libgdx_test;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Window.WindowStyle;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;

//This is an easy class to hold the skins that are used in the scene2d elements
public class ClassSkinReference {
	private Skin skin_01, skin_02, skin_03;
	ClassLogDisplay logger;
	ClassSkinReference(){
		logger = new ClassLogDisplay("ActivityIndex");
		skin_01 = new Skin();
		skin_02 = new Skin();
		skin_03 = new Skin();
		pixmap_skins();
		label_skins();
		textbutton_skins();
		window_style_skins();
	}
	private void label_skins(){
		LabelStyle labelStyle = new LabelStyle();
		labelStyle.font = skin_01.getFont("default");
		labelStyle.fontColor = Color.WHITE;
		skin_01.add("default", labelStyle);
		
		
		LabelStyle alt_labelStyle = new LabelStyle();
		alt_labelStyle.font = skin_01.getFont("default");
		alt_labelStyle.fontColor = Color.WHITE;
		skin_02.add("default", alt_labelStyle);
		
		/*LabelStyle alt_labelStyle = new LabelStyle(labelStyle);
		Color background_color = new Color();
		background_color.set(0, 0, 0, (float) .5);
		alt_labelStyle.background = skin_02.newDrawable("white", background_color);
		skin_02.add("default", alt_labelStyle);*/

		skin_03.add("default", labelStyle);
	}
	private void textbutton_skins(){
		
		Drawable dialog_up = new TextureRegionDrawable(new TextureRegion(new Texture("data/dialog_button_up.png")));
		Drawable dialog_down = new TextureRegionDrawable(new TextureRegion(new Texture("data/dialog_button_down.png")));
		
		Drawable selection_up = new TextureRegionDrawable(new TextureRegion(new Texture("data/selection_button_up.png")));
		Drawable selection_down = new TextureRegionDrawable(new TextureRegion(new Texture("data/selection_button_down.png")));
		
		TextButtonStyle textButtonStyle = new TextButtonStyle();
		textButtonStyle.up = skin_01.newDrawable("white", Color.DARK_GRAY);
		textButtonStyle.down = skin_01.newDrawable("white", Color.LIGHT_GRAY);
		textButtonStyle.over = skin_01.newDrawable("white", Color.LIGHT_GRAY);
		textButtonStyle.font = skin_01.getFont("default");
		textButtonStyle.font = new BitmapFont();
		textButtonStyle.font.setScale(2);
		skin_01.add("default", textButtonStyle);
		
		TextButtonStyle alt_style = new TextButtonStyle();
		alt_style.up = dialog_up;
		alt_style.down = dialog_down;
		alt_style.over = dialog_down;
		//alt_style.up = skin_02.newDrawable("white", Color.DARK_GRAY);
		//alt_style.down = skin_02.newDrawable("white", Color.LIGHT_GRAY);
		//alt_style.over = skin_02.newDrawable("white", Color.LIGHT_GRAY);
		alt_style.font = skin_02.getFont("default");
		alt_style.font = new BitmapFont();
		alt_style.font.setScale(2);
		skin_02.add("default", alt_style);
		
		TextButtonStyle button_style = new TextButtonStyle();
		//button_style.up = skin_03.newDrawable("white", Color.DARK_GRAY);
		//button_style.down = skin_03.newDrawable("white", Color.LIGHT_GRAY);
		//button_style.over = skin_03.newDrawable("white", Color.LIGHT_GRAY);
		
		button_style.up = selection_up;
		button_style.down = selection_down;
		button_style.over = selection_down;
		
		button_style.font = skin_03.getFont("default");
		button_style.font = new BitmapFont();
		button_style.font.setScale(2);
		skin_03.add("default", button_style);
	}
	private void window_style_skins(){
		//titleFont: default-font, background: default-window, titleFontColor: white
		
		WindowStyle window_style = new WindowStyle();
		window_style.titleFont = new BitmapFont();
		window_style.titleFont.setColor(Color.WHITE);
		window_style.titleFont.setScale(3);
		
		//new TextureRegionDrawable(new TextureRegion(new Texture("data/splitpane.png")));
		window_style.background = new TextureRegionDrawable(new TextureRegion(new Texture("data/dialog_box.png")));
		skin_01.add("default", window_style);
		skin_02.add("default", window_style);
		skin_03.add("default", window_style);
	}
	private void pixmap_skins(){
		Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888);
		pixmap.setColor(Color.WHITE);
		pixmap.fill();
		skin_01.add("default", new BitmapFont());
		skin_01.add("white", new Texture(pixmap));
		
		Pixmap alternate_pixmap = new Pixmap(4, 4, Format.RGBA8888);
		alternate_pixmap.setColor(Color.WHITE);
		alternate_pixmap.fill();
		skin_02.add("default", new BitmapFont());
		skin_02.add("white", new Texture(alternate_pixmap));
		
		skin_03.add("default", new BitmapFont());
		skin_03.add("white", new Texture(pixmap));
	}
	public Skin get_skin(){
		return skin_01;
	}
	public Skin get_alternate_skin(){
		return skin_02;
	}
	public Skin get_button_skin(){
		return skin_03;
	}
}
